import java.awt.event.*
import javax.swing.*

fileChooser = fileChooser(dialogTitle:'Open SQL File', fileSelectionMode : JFileChooser.FILES_ONLY)

application(title:'SqlPortable', size:[600,400], locationByPlatform:true,    
    iconImage: imageIcon('/griffon-icon-48x48.png').image,
    iconImages: [imageIcon('/griffon-icon-48x48.png').image,
                 imageIcon('/griffon-icon-32x32.png').image,
                 imageIcon('/griffon-icon-16x16.png').image]) {

    fileChooser(dialogTitle:'Open SQL File', fileSelectionMode:JFileChooser.FILES_ONLY, actionPerformed:controller.&openFile)
    menuBar() {
        menu(text:'File') {
            menuItem(text:'Open', actionPerformed:controller.&openFile)
        }
        menu(text:'Run') {
            menuItem(text:'Run', actionPerformed:controller.&execute,
                accelerator:KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_MASK))
        }
    }

    splitPane(orientation:JSplitPane.VERTICAL_SPLIT, dividerLocation:200) {
        scrollPane() {
            editor = textArea(tabSize:2, text:bind {model.sql})
        }
        tab = tabbedPane() {
            resultPane = scrollPane(title:'Search Result') {
                table = table()
            }
            consolePane = scrollPane(title:'Console', autoscrolls:true) {
                console = textArea(tabSize:2)
            }
        }
    }
}